<div data-ng-controller="contractPerformanceCtrl">
    <div class="table-header clearfix ng-scope">
        <span class="fl lh30 f14">{{contractBaseInfo.contract_code}}</span>
    </div>

    <form class="form-horizontal">
        <div class="form-group mt10">
            <span for="inputtext3" class="col-sm-3 control-label">合同成交折扣(%) :</span>

            <div class="col-sm-5">
                <input type="number" class="form-control" ng-value="contractPfmInfo.contract_deal_discount|percent|number:0"
                       placeholder="合同成交折扣" disabled>
            </div>
            <span for="inputtext3" class="col-sm-3 control-label">提成项目数:</span>

            <div class="col-sm-5">
                <input type="number" class="form-control" ng-model="contractPfmInfo.draw_project_numeric"
                       placeholder="提成项目数">
            </div>
        </div>

        <div class="mt20 clearfix ng-scope ml25">
            <span class="fl lh30 f14">签约业绩</span>
        </div>
        <div class="table-wrap mt10 ml25" style="min-height: 200px;overflow: visible">

            <table width="100%" class="valign-t">
                <thead>
                <tr>
                    <th style="width: 35px;">序号</th>
                    <th style="width: 90px;" class="align-r">签约业绩金额</th>
                    <th style="width: 100px;" class="align-m">业绩归属时间</th>
                    <th style="width: 200px;">业绩归属信息</th>
                    <th style="width: 200px;">ERP业绩归属信息</th>
                    <th style="width: 130px;">ERP业绩归属客户经理</th>
                    <th style="width: 120px;">ERP业绩归属部门</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="record in contractPfmInfo.signAchievements" ng-if="record.__type != 'delete'"
                    style="line-height: 35px;">
                    <td><p ng-bind="$index + 1"></p></td>
                    <td class="align-r">
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.achievement_amount | number:2"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input type="text" ng-model="record.achievement_amount" class="form-control"
                                   placeholder="签约业绩金额">
                        </p>
                    </td>
                    <td class="align-m">
                        <p ng-bind="record.achievement_belong_time|strdate:'yyyy-MM-dd'"></p>
                    </td>
                    <td style="line-height: 27px;">
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="'归属人：'+record.belong_name"></p>

                        <p ng-if="(record.editMode || 0) != 0" style="position:relative;">归属人：
                            <input name="belong_by" select2 ng-model="record.belong_by" style="position: absolute;top: 0;width: 146px;right: 0;"
                                   select2-model="record.ddl2BelongBy" data="record"
                                   config="ddlConfigBelongBy" type="text" placeholder="业绩归属人"
                                   class="form-control idBelongBy1">
                        </p>
                        <p ng-bind="'归属部门：'+record.department_name"></p>
                        <p ng-bind="'归属区域：'+record.area_name"></p>
                    </td>
                    <td style="line-height: 27px;">
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="'归属人：'+record.erp_achievement_belong_name"></p>

                        <p ng-if="(record.editMode || 0) != 0" style="position:relative;">归属人：
                            <input name="belong_by" select2 ng-model="record.erp_achievement_belong" style="position: absolute;top: 0;width: 146px;right: 0;"
                                   select2-model="record.ddl2BelongBy" data="record"
                                   config="ddlConfigErpBelongBy" type="text" placeholder="ERP业绩归属人"
                                   class="form-control idErpBelongBy">
                        </p>
                        <p ng-bind="'归属ABU：'+record.erp_achievement_belong_abu_name"></p>
                        <p ng-bind="'归属ABU负责人：'+record.erp_achievement_belong_abu_owner_name"></p>
                        <p ng-bind="'归属部门经理：'+record.erp_achievement_belong_bu_manager_name"></p>
                    </td>

                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.manager_name || null"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input name="manager_by" select2 ng-model="record.manager_by"
                                   select2-model="record.ddl2ManagerBy" data="record"
                                   config="ddlConfigManagerBy" type="text" placeholder="ERP客户经理"
                                   class="form-control idManagerBy1">
                        </p>
                    </td>
                    <td>
                        <p ng-bind="record.erp_achievement_belong_bu_name"></p>
                    </td>
                    <td>
                        <div row-toolbar min-buttons-show="3" ng-if="contractBaseInfo.is_cancelled == 0">
                            <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                               title="拆分业绩信息"
                               ng-click="addSignAchievement(contractPfmInfo.signAchievements,record)">拆分</a>
                            <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                               title="修改业绩信息"
                               ng-click="editSignAchievement(record, $index,contractPfmInfo.signAchievements)">修改</a>
                            <a ng-if="(record.editMode || 0)  == 0 && contractPfmInfo.signAchievements.length>1"
                               ng-click="delSignAchievement(record,$index,contractPfmInfo.signAchievements)"
                               href="javascript:void(0)"
                               title="删除业绩信息">删除</a>

                            <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                               title="保存业绩信息"
                               ng-click="saveSignAchievement(record)">确定</a>
                            <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                               title="取消修改业绩信息"
                               ng-click="cancelSignAchievement(record, $index,contractPfmInfo.signAchievements)">取消</a>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="no-data" ng-if="contractPfmInfo.signAchievements.length == 0"><span>暂无数据</span></div>
        </div>
        <div class="mt10 ml25">
            <span class="pl10">说明：{{contractBaseInfo|signOrBalanceLabel}}(<em class="b">{{contractBaseInfo|signOrBalanceAmount|number:2}}</em>元)
            = 已确定业绩（<em class="b">{{contractPfmInfo.signAchievements|sumSignAmount|number:2}}</em>元） + 待确定业绩（<em
                        class="b c-red">{{contractPfmInfo.signAchievements|remainSignAmount:contractBaseInfo|number:2}}</em>元）
            </span>
        </div>

        <div class="mt20 clearfix ng-scope ml25">
            <span class="fl lh30 f14">回款业绩</span>
        </div>
        <div class="table-wrap mt10 ml25" style="min-height: 200px;overflow: visible">

            <table width="100%" class="valign-t">
                <thead>
                <tr>
                    <th style="width: 35px;">序号</th>
                    <th style="width: 120px;">款项信息</th>
                    <th style="width: 90px;">回款业绩金额</th>
                    <th style="width: 100px;">实收时间</th>
                    <th style="width: 200px;">业绩归属信息</th>
                    <th style="width: 200px;">ERP业绩归属信息</th>
                    <th style="width: 140px;">ERP业绩归属客户经理</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="record in contractPfmInfo.paymentAchievement" ng-if="record.__type != 'delete'"
                    style="line-height: 35px;">
                    <td style="text-align: center;"><p ng-bind="$index + 1"></p></td>
                    <td>
                        <p ng-bind="'名称：'+record.receivable_item_name"></p>
                        <p ng-bind="'小类：'+record.money_category_item_name"></p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.achievement_amount | number:2"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input type="text" ng-model="record.achievement_amount" class="form-control"
                                   placeholder="回款业绩金额">
                        </p>
                    </td>
                    <td>
                        <p ng-bind="record.received_time|strdate:'yyyy-MM-dd'"></p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="'归属人：'+record.belong_name"></p>

                        <p ng-if="(record.editMode || 0) != 0" style="position:relative;">归属人：
                            <input name="belong_by" select2 ng-model="record.belong_by" style="position: absolute;top: 0;width: 146px;right: 0;"
                                   select2-model="record.ddl2BelongBy" data="record"
                                   config="ddlConfigBelongBy" type="text" placeholder="业绩归属人"
                                   class="form-control idBelongBy2">
                        </p>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="'归属时间：'+(record.achievement_belong_time|strdate:'yyyy-MM-dd')"></p>

                        <p ng-if="(record.editMode || 0) != 0" style="position:relative;">归属时间：
                                <input type="text" class="input-date fl form-control" style="position: absolute;top: 0;width: 136px;right: 0;"
                                    ui-date format="yyyy-MM-dd" ng-model="record.achievement_belong_time" placeholder="业绩归属时间">
                        </p>

                        <p ng-bind="'归属部门：'+record.department_name"></p>
                        <p ng-bind="'归属区域：'+record.area_name"></p>
                    </td>
                    <td style="line-height: 27px;">
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="'归属人：'+record.erp_achievement_belong_name"></p>

                        <p ng-if="(record.editMode || 0) != 0" style="position:relative;">归属人：
                            <input name="belong_by" select2 ng-model="record.erp_achievement_belong" style="position: absolute;top: 0;width: 146px;right: 0;"
                                   select2-model="record.ddl2BelongBy" data="record"
                                   config="ddlConfigErpBelongBy" type="text" placeholder="ERP业绩归属人"
                                   class="form-control idErpBelongBy">
                        </p>
                        <p ng-bind="'归属ABU：'+record.erp_achievement_belong_abu_name"></p>
                        <p ng-bind="'归属ABU负责人：'+record.erp_achievement_belong_abu_owner_name"></p>
                        <p ng-bind="'归属部门经理：'+record.erp_achievement_belong_bu_manager_name"></p>
                    </td>

                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="'客户经理：'+record.manager_name || null"></p>

                        <p ng-if="(record.editMode || 0) != 0" style="position:relative;">客户经理：
                            <input name="manager_by" select2 ng-model="record.manager_by" style="position: absolute;top: 0;width: 137px;right: 0;"
                                   select2-model="record.ddl2ManagerBy" data="record"
                                   config="ddlConfigManagerBy" type="text" placeholder="ERP客户经理"
                                   class="form-control idManagerBy2">
                        </p>
                        <p ng-bind="'归属部门：'+record.erp_achievement_belong_bu_name"></p>
                    </td>
                    <td>
                        <div row-toolbar min-buttons-show="3" ng-if="contractBaseInfo.contract_status == 2 && contractBaseInfo.is_cancelled == 0">
                            <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                               title="拆分业绩信息"
                               ng-click="addSignAchievement(contractPfmInfo.paymentAchievement,record)">拆分</a>
                            <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                               title="修改业绩信息"
                               ng-click="editSignAchievement(record, $index,contractPfmInfo.paymentAchievement)">修改</a>
                            <a ng-if="(record.editMode || 0)  == 0 && contractPfmInfo.paymentAchievement.length>1"
                               ng-click="delSignAchievement(record,$index,contractPfmInfo.paymentAchievement)"
                               href="javascript:void(0)"
                               title="删除业绩信息">删除</a>

                            <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                               title="保存业绩信息"
                               ng-click="saveSignAchievement(record)">确定</a>
                            <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                               title="取消修改业绩信息"
                               ng-click="cancelSignAchievement(record, $index,contractPfmInfo.paymentAchievement)">取消</a>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="no-data" ng-if="contractPfmInfo.paymentAchievement.length == 0" style="height:180px">
                <span>暂无数据</span></div>
        </div>

        <div class="form-group">
            <div class="ml35 mt15">
                <button type="button" ng-click="save()" class="btn btn-default" ng-disabled="saveEnabled()" ng-if="contractBaseInfo.is_cancelled == 0">
                    保存
                </button>
            </div>
        </div>
    </form>
</div>